<template>
  <div id="app">
    <van-button type="primary">主要按钮</van-button>
    <van-checkbox v-model="checked">复选框</van-checkbox>{{checked}}
    <div class="box"></div>
    <button @click="fn">点我发送请求</button>
    <router-view/>
  </div>
</template>

<script>
import request from '@/utils/request'
import { setToken } from '@/utils/storage'
export default {
  name: 'App',
  data () {
    return {
      checked: true
    }
  },
  methods: {
    async fn () {
      // 我们在这里只需要使用 request.post就可以发送请求了 注册
      // const res = await request.post('/user/register', {
      //   username: 'shuaipeng10',
      //   password: '123456'
      // })

      // 登录
      const res = await request.post('/user/login', {
        username: 'shuaipeng10',
        password: '123456'
      })
      setToken(res.data.token)
      console.log(res)
    }
  }
}
</script>

<style lang="less">
.box{
  width: 200px;
  height: 200px;
  background-color: pink;
}
</style>
